package org.timeismoney.payment.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Property;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.timeismoney.payment.dao.UnitLevelDao;
import org.timeismoney.payment.model.UnitLevel;

public class UnitLevelDaoImpl extends GenericDaoImpl<UnitLevel, Integer> implements
		UnitLevelDao {

	public UnitLevelDaoImpl(){
		this.setClazz(UnitLevel.class);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<UnitLevel> getEntitys() {
		return (List<UnitLevel>) getHibernateTemplate().execute(new HibernateCallback() {
			
			public Object doInHibernate(Session session) throws HibernateException,
					SQLException {
				return session.createCriteria(clazz).addOrder(Property.forName("sortNo").asc()).list();
			}
		});
	}

}
